<?php

namespace JsonLowCode\Form\Fields;

use JsonLowCode\UI\Slider;
use JsonLowCode\Form\Abstract\FieldAbstract;
use JsonLowCode\Form\Traits\HasDisabled;

/**
 * @property Slider $element
 */
class SliderField extends FieldAbstract
{
    use HasDisabled;

    protected string|null $placeholder = null;

    protected function booting(): void
    {
        $this->element = new Slider();
        $this->styles(['min-width'=>"200px"]);
    }


    /**
     * 最小值
     * @param float|int|string $step
     * @param bool $isJSExpression
     * @return $this
     */
    public function min(float|int|string $step = 1, bool $isJSExpression = false): static
    {
        $this->element->min($step, $isJSExpression);
        return $this;
    }

    /**
     * 最大值
     * @param float|int|string $step
     * @param bool $isJSExpression
     * @return $this
     */
    public function max(float|int|string $step = 1, bool $isJSExpression = false): static
    {
        $this->element->max($step, $isJSExpression);
        return $this;
    }

    /**
     * 步进值
     * @param float|int|string $step number|'mark'
     * @param bool $isJSExpression
     * @return $this
     */
    public function step(float|int|string $step = 1, bool $isJSExpression = false): static
    {
        $this->element->step($step, $isJSExpression);
        return $this;
    }

    /**
     * 只读禁用
     * @param string|bool $bool
     * @param bool $isJSExpression 是否js表达式
     * @return $this
     */
    public function readonly(string|bool $bool = true,  bool $isJSExpression = false): static
    {
        return $this->disabled($bool, $isJSExpression);
    }
}
